﻿$(function() {
    CategoryCreate.init();
    Utils.textBoxsOnEnter(CategoryCreate.Create);
});


var CategoryCreate =
{
    init: function() {
        $("#btnSave").click(this.Create);
        $("#category").focus();
        $(document).keyup(function(e) {
            if (e.keyCode == 27) {
                var needConfirm = utility.hasFormData();
                window.parent.utility.closePopUpUrlConfirm(needConfirm);
            }
        });
    },
    Create: function() {
        var category = $("#category");

        targetFunction = (parent != undefined) ? parent.ErrorHelper : ErrorHelper;
        targetFunction.checkNonNull(category, m.Err1107);
        if (!targetFunction.popUpIfError()) {
            var param = {
                category: category.val()
            };
            var cb = Utils.getCBfunction('Voice', 'CategoryIndex');
            var ecb = function() { $("#category").focus(); };
            window.parent.utility.ajaxext("VoiceService/CreateVoiceCategory", param, "POST", cb, ecb);
        }
    }
};
